const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const userInfo = {};
const questions = [
  { text: '请输入姓名: ', key: 'name' },
  { text: '请输入邮箱: ', key: 'email' },
  { text: '请输入QQ号: ', key: 'qq' },
  { text: '请输入手机号码: ', key: 'phone' }
];

let current = 0;

function askQuestion() {
  if (current < questions.length) {
    rl.question(questions[current].text, (answer) => {
      userInfo[questions[current].key] = answer;
      current++;
      askQuestion();
    });
  } else {
    console.log('\n收集到的用户信息:');
    console.log(userInfo);
    rl.close();
  }
}

askQuestion();